﻿<UserControl x:Class="TheVerge.Phone.Controls.InfiniteScroller"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:con="clr-namespace:TheVerge.Phone.Controls"
    xmlns:conv="clr-namespace:TheVerge.Phone.Converters"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    x:Name="infinScroll">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <con:ProgressBar Grid.Row="0" Margin="6" IsIndeterminate="{Binding IsRefreshing}" Visibility="{Binding IsRefreshing, Converter={StaticResource trueVisConv}}"  />
        <con:ProgressBar Grid.Row="2" Margin="6" IsIndeterminate="{Binding IsLoading}" Visibility="{Binding IsLoading, Converter={StaticResource trueVisConv}}" />

        <con:FlashBar Grid.Row="0" Margin="6" Height="5" IsAnimating="{Binding IsRefreshing, Converter={StaticResource invConv}}" />
        <con:FlashBar Grid.Row="2" Margin="6" Height="5" IsAnimating="{Binding IsLoading, Converter={StaticResource invConv}}" DoNotShowOnFirstToggleOfIsAnimating="True" />

        <con:InfiniteListbox x:Name="listbox" Grid.Row="1" ItemDrawn="Listbox_ItemDrawn" AtTop="Listbox_AtTop"
                             Style="{StaticResource ilbStyle}"
                              ItemsSource="{Binding Items}"
                              ItemTemplate="{Binding ElementName=infinScroll, Path=ItemTemplate}"
                              />

        <TextBlock Text="No Items" Grid.Row="1"
                   HorizontalAlignment="Center" VerticalAlignment="Center"
                   Style="{StaticResource PhoneTextTitle2Style}"
                   Visibility="{Binding HasItems, Converter={StaticResource falseVisConv}}" />
    </Grid>
</UserControl>
